﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HammerMUD.System;
using HammerMUD.Items;
using HammerMUD.Rooms;

namespace HammerMUD.Commands
{
    public class DropCommand : Command
    {
        public DropCommand()
        {
            Name = "drop";
            Help = "drop <item>";
            SecurityLevel = HammerMUD.Admin.SecurityLevel.User;
        }

        public override void Do(User from, List<String> arguments)
        {
            if (arguments.Count == 1)
            {
                from.Send(Help);
                return;
            }

            foreach (Item i in from.UserAccount.CurrentCharacter.Inventory)
            {
                if (i.Name.ToLower().Equals(arguments[1]))
                {
                    from.UserAccount.CurrentCharacter.Inventory.Remove(i);
                    from.UserAccount.CurrentCharacter.CurrentRoom.Items.Add(i);
                    from.Send("You drop " + i.Name);
                    RoomUtilities.SendToRoom(from, from.UserAccount.CurrentCharacter.Name + " drops a " + i.Name);
                    return;
                }
            }

            from.Send("You don't have that item!");
            return;
        }
    }
}
